package ppl.tut1

abstract class Element {

   def contents: Array[String]
   def height = contents.length
   def width = if (height == 0) 0 else contents(0).length

   def checkEqual(that: Element): Boolean = {
      this.contents.sameElements(that.contents)
      //or this.contents.deep == that.contents.deep
   }
}

object Element {
   def elem(contents: Array[String]): Element = {
      new ArrayElement(contents)
   }

   def elem(line: String): Element = {
      new LineElement(line)
   }

   def elem(c: Char, row: Int, col: Int): Element = {
      new UniformElement(c, row, col)
   }

   //main for run
   def main(args: Array[String]): Unit = {
      var c1 = new Rational(1, 3)
      var c2 = new Rational(2, 4)
      var d = 2;
      println(c1 + c2)
      println(c2 + d)

      val arr = Element.elem(Array("ccc", "ccc", "ccc"))
      val uni = Element.elem('c', 3, 3)
      println(arr.checkEqual(uni))
   }
}

/*
*
*
*
*
*
*/ 